﻿using System;
using System.Collections.Generic;
using System.Text;
using UtilZ.Dotnet.Ex.Base;

namespace UtilZ.Dotnet.Ex.Communication.Net.Telnet.KeyCommands
{
    internal class Pause_BreakCommand : TelnetKeyCommandAbs
    {
        /**********************************************
        *          windows      linux      mac
        * code     27-91-80     27-91-80   27-91-50-56-126
        **********************************************/

        public Pause_BreakCommand()
              : base()
        {

        }

        protected override bool PrimitveProcess(ListenTelnetClient telnetClient, byte[] data, int revicedDataLength)
        {
            if (revicedDataLength == 3 && (telnetClient.Platform == OSPlatformID.Win || telnetClient.Platform == OSPlatformID.Linux_Unix) && data[0] == 27 && data[1] == 91 && data[2] == 80 ||
                revicedDataLength == 5 && telnetClient.Platform == OSPlatformID.MacOS && data[0] == 27 && data[1] == 91 && data[2] == 50 && data[3] == 56 && data[4] == 126)
            {
                base.SendEcho(telnetClient, data, revicedDataLength);
                return true;
            }

            return false;
        }
    }
}
